<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
    <title>留言板</title>
    <link rel="stylesheet"  href="/Netease_Cloud/css/style.css">
    <script type="text/javascript" src="/Netease_Cloud/js/jquery-1.10.2.js" ></script>
</head>
<body>
<div class="m-top">
    <div class="wrap">
        <h1 class="logo"></h1>
        <h3 class="title">留言板</h3>
    </div>
</div>
<div class="wrap">
    <div class="g-ma">
        <div class="u-title">
            <h3>发帖</h3>
        </div>
        <div class="m-cmmt">
            <div class="iptarea">
                <div class="head">
                    <a href="<s:property value="#request.get('javax.servlet.forward.context_path')" />/my/index"><img src="/Netease_Cloud/images/head/default.jpg"/></a>
                </div>
                <div class="f-pr">
                    <textarea class="u-txt" placeholder="评论"></textarea>
                </div>
                <div class="btn">
                    <a href="#" class="u-btn">评论</a>
                </div>
            </div>
            <h3 class="u-hd4">精彩评论</h3>
            <s:iterator value="#session.Leavelist"  var="li"  status="item">
                <div class="itm">
                    <div class="head"><a href="#"><img src="/Netease_Cloud/images/files/<s:property value="#li.user_img"></s:property>"></a></div>
                    <div class="cntwrap"><div><div class="cnt f-brk"><a href="#" class="s-fc7"><s:property value="#li.user_name"></s:property></a>：<s:property value="#li.comment"></s:property></div></div>
                        <s:iterator value="#session.comm"  var="co"  status="item">
                            <s:if test="#li.id == #co.leave_id">
                                <div class="que"><img src="/Netease_Cloud/images/files/<s:property value="#co.user_img"></s:property>" /><a class="s-fc7" href="#"><s:property value="#co.user_name" /></a>：<s:property value="#co.comment_hf" /></div>
                            </s:if>
                            <br>
<%--                            <s:if test='{#li.id==#co.leave_id}'>--%>
<%--                                --%>
<%--                            </s:if>--%>
                        </s:iterator>
                        <div class="rp"><div class="time s-fc4">11月9日 00:00</div>
                            <a href="#" class="s-fc3" id="dj<s:property value="#li.endorse"></s:property>">
                                <i class="zan"></i>
                                (<span class="sp" index="<s:property value="#item.index+1"/>"><s:property value="#li.endorse"></s:property></span>)
                                <input class="sinp" type="hidden" value="<s:property value="#li.id"/>">
                            </a>
                            <span class="sep">|</span>
                            <a href="<s:property value="#request.get('javax.servlet.forward.context_path')" />/hf/index?user_name=<s:property value="#li.user_name"/>&user_img=<s:property value="#li.user_img"/>&leave_id=<s:property value="#li.id"/>" class="s-fc3">回复</a></div></div>
            </s:iterator>

        </div>
    </div>
</div>
<script>
    $(function (){
        $(".u-btn").click(function (){
            let val = $(".u-txt").val();
            console.log(val);
            $.ajax({
                type:"post",
                data:{
                    "ly":val,
                    "user_name":"${user.uname}",
                    "user_img":"${user.img}",
                },
                url:"http://localhost:9090/Netease_Cloud/index/index",
                "success":function(data){
                    console.log(data)
                }
            })
        })
        $(".s-fc3").click(function (){
            let find = $(this).find(".sp");
            var a=parseInt(find.text())+1;
            find.html(a);
            $.ajax({
                type:"post",
                data:{
                    "zan":a,
                    "leave_id":parseInt($(this).find(".sinp").val())
                },
                url:"http://localhost:9090/Netease_Cloud/zan/index",
                "success":function(data){
                    console.log(data)
                }
            })
        })
    })
</script>
</body>
</html>